﻿using System.Collections.Generic;
using System.Linq;
using Framework.Poco;
using Shell.DomainDot;

namespace Framework.Domain
{
    /// <summary>
    /// 文章选择器
    /// </summary>
    public class SelectArticleByCategory : DomainDotBase<Category>
    {
        /// <summary>
        /// 指定分类的文章
        /// </summary>
        public WithMany<Article> Article { get; set; }

        /// <summary>
        /// 获取指定分类的文章并分页
        /// </summary>
        public IEnumerable<Article> Select(int currentPage, int pageSize, out int total)
        {
            total = this.Article.Count;
            return this.Article.Skip((currentPage - 1) * pageSize).Take(pageSize);
        }
    }
}
